import * as THREE from 'three'
import Experience from './Experience';
import { EventEmitter } from 'events'
export default class Time extends EventEmitter {
    constructor() {
        super();
        this.start = Date.now();
        this.current = this.start
        this.elapsed = 0; // 经过的时间
        this.delta = 16; // 每帧之间的事件

        this.update()
    }
    update() {
        const currentTime = Date.now();
        this.delta = currentTime - this.current;
        this.current = currentTime;
        this.elapsed = this.current - this.start;
        // console.log(this.delta);

        this.emit("update");
        window.requestAnimationFrame(() => this.update())
    }
}